#!/bin/bash

export GOBIN=$(pwd)/bin

# -----------------------------------------------

echo installing game ...
go install "$@" cade/src/game

echo installing gate ...
go install cade/src/gate

echo installing bot ...
go install cade/src/bot

# -----------------------------------------------

echo preparing data ...
cp src/config.json bin/

[ -d bin/gamedata ] && rm -rf bin/gamedata/* || mkdir bin/gamedata
cp -R src/game/app/gamedata/data   bin/gamedata
cp -R src/game/app/gamedata/filter bin/gamedata

# -----------------------------------------------

echo setup server topology

cat > bin/SERVERS <<'EOF'
SERVERS=(
"game1          ./game   -config config.json -server game1   -log game1.log  "
"gate1          ./gate   -config config.json -server gate1   -log gate1.log  "
)
EOF

# -----------------------------------------------

echo preparing control script
cp ctl.sh bin

# -----------------------------------------------

echo -e "\033[32mDone\033[0m"
